import groovy.jmx.builder.modelmbean.ModelMBeanAttributeCollector

class ModelMBeanAttributeCollectorTest extends GroovyTestCase {
    def dataGenerator
    def collector

    void setUp() {
        dataGenerator = new NodeDataGenerator()
        collector = new ModelMBeanAttributeCollector()
    }

    void testCollectAttributeInfoFromNodeData() {
        def treeNode = dataGenerator.generateMBeanNodeData()
        assert treeNode != null

        def info = collector.collectAttributeInfo(treeNode)
        assert info != null
        assert info.size() == 4
    }

    void testCollectAttributeInfoFromInstance() {
        def instance = new ExposedTestBean()
        def info = collector.collectAttributeInfo(instance)
        assert info != null
        assert info.size() == 5
    }

    void testCollectAttributeInfoFromJavaInstance() {
        def instance = new TestJavaBean()
        def info = collector.collectAttributeInfo(instance)
        assert info != null
        assert info.size() == 3
    }

}